'use strict';
// Copyright 2014 Blueant Inc. All Rights Reserved.

/**
 * @fileoverview 远征对手信息
 * @author agl
 */

var mongoose = require('mongoose');

// 虚弱(未用)
var WeaknessItemSchema = new mongoose.Schema({
    weakness_type: Number,
    weakness_value: Number,
});

// 抗性(保留)
var ResistanceItemSchema = new mongoose.Schema({
    resistance_type: Number,
    resistance_value: Number,
});

// 士兵属性
var soldierAttrSchema = new mongoose.Schema({
    soldier_type: Number,
    produce_time: Number,
    command: Number,
    min_atk: Number,
    max_atk: Number,
    fire_damage: Number,
    ice_damage: Number,
    light_damage: Number,
    city_damage: Number,
    physical_def: Number,
    fire_def: Number,
    ice_def: Number,
    light_def: Number,
    city_def: Number,
    physical_bounce: Number,
    fire_bounce: Number,
    ice_bounce: Number,
    light_bounce: Number,
    city_bounce: Number,
    hp: Number,
    curr_hp: Number,
    crit_addition: Number,
    atk_interval: Number,
    atk_range: Number,
    warn_range: Number,
    speed: Number,
    atk_kind: Number,
    ratio_break_effect: Number,
    ratio_burn_effect: Number,
    ratio_ice_effect: Number,
    ratio_palsy_effect: Number,
    ratio_un_break_effect: Number,
    ratio_un_burn_effect: Number,
    ratio_un_ice_effect: Number,
    ratio_un_palsy_effect: Number,
    weakness_list: [WeaknessItemSchema],
    resistance_list: [ResistanceItemSchema],
    aoe_radius: Number,
    skill_ratio: Number,
});

// 士兵信息
var soldierInfoSchema = new mongoose.Schema({
    soldier_type: Number,
    lv: Number,
    star: Number,
    produce_time: Number,
    command: Number,
    first_attack: Number,
    num: Number,
    aoe_radius: Number,
    attr: soldierAttrSchema,
});

// 科技信息
var techInfoSchema = new mongoose.Schema({
    tech_type: Number,
    tech_eff: Number
});

///////////////////////////////////////////////////////////

/**
 * 远征对手信息
 */
var rivalItemSchema = new mongoose.Schema({
    // 角色ID
    role_id: {
        type: Number,
        required: true
    },

    // 名称
    name: {
        type: String,
        required: true
    },

    // 等级
    lv: {
        type: Number,
        required: true
    },

    // 职业
    job_type: {
        type: Number,
        required: true
    },

    // 排名
    rank: {
        type: Number,
        required: true
    },

    // 战力
    soldier_power: {
        type: Number,
        required: true
    },

    // 士兵列表
    soldier_list: {
        type: [soldierInfoSchema],
        default: []
    },

    // 联盟士兵加成科技列表
    union_tech_eff: {
        type: [techInfoSchema],
        default: []
    }
});

if (!rivalItemSchema.options.toJSON) {
    rivalItemSchema.options.toJSON = {};
}
/* jshint unused:false */
rivalItemSchema.options.toJSON.transform = function (doc, ret) {
    delete ret._id;
    delete ret.__v;
};

module.exports = rivalItemSchema;
